package com.situ.company.score.service.impl;

import java.util.List;

import com.situ.company.project.model.ProjectModel;
import com.situ.company.score.dao.IScoreDao;
import com.situ.company.score.dao.impl.ScoreDaoImpl;
import com.situ.company.score.model.ScoreModel;
import com.situ.company.score.service.IScoreService;
import com.situ.company.util.FmtEmpty;

public class ScoreServiceImpl implements IScoreService {

	IScoreDao dao=new ScoreDaoImpl();
	public String insert(ScoreModel model) {
		return dao.insert(model)+"";
	}

	public String delete(ScoreModel model) {
		ScoreModel s0=new ScoreModel();
		s0.setCodeEmp(model.getCodeEmp());
		s0.setCodePro(model.getCodePro());
		ScoreModel s1 = selectModel(s0);
		if(FmtEmpty.isEmpty(s1.getScore())) {
			return dao.delete(model)+"";
		}else {
			return "exist";
		}
		
	}

	public String update(ScoreModel model) {
		return dao.update(model)+"";
	}

	public List<ScoreModel> selectList(ScoreModel model) {
		String codeEmp=model.getCodeEmp();
		model.setCodeEmp(codeEmp==null?"%%":"%"+codeEmp+"%");
		String codePro=model.getCodePro();
		model.setCodePro(codePro==null?"%%":"%"+codePro+"%");
		return dao.selectList(model);
	}

	public Integer selectCount(ScoreModel model) {
		ScoreModel s0=new ScoreModel();
		return dao.selectCount(s0);
	}

	public ScoreModel selectModel(ScoreModel model) {
		return dao.selectModel(model);
	}

}
